/*
Web: http://www.jsForms.com
Copyright (C) 2008  Igor Demyanov (mailto:Igor.Demyanov@gmail.com)
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
jsForms.Components.Expander = {
	Init:function()
	{
		if (this.Properties.isExpand==undefined)
		{
			this.Properties.isExpand = true;
		}
		this.Components.header_button.bind("click",this,this.eventHeaderButtonClick);
		jsForms.Components.Component.Init.call(this);
		return this;
	},
	Toggle:function()
	{
		console.log(this._Name+':Expander.Toggle');
			if (this.Properties.isExpand)
			{
				this.Collapse();
			}else
			{
				this.Expand();
			}
		return this;
	},
	Expand: function(){
		console.log(this._Name+':Expander.Expand');
		this.Properties.isExpand = true;
		this.Components.content.show();
		return this;
	},
	Collapse:function()
	{
		console.log(this._Name+':Expander.Collapse');
		this.Properties.isExpand = false;
		this.Components.content.hide();
		return this;
	},
	SetHeaderText: function(value)
	{
		this.Components.header_text[0].innerHTML = value;
		return this;
	},
	eventHeaderButtonClick:function(e)
	{
		if(!e.data) return;
		e.data.Toggle.call(e.data);
	}
};

// -----------------------------------------------
// Compilation INFO
// -----------------------------------------------
jsForms.CreateCompileInfoByObject(
{
	Name: 'Expander',
	Properties: {
		HeaderText: {
			Type: 'string',
			Access: 'SET'
		}
	},
	Events: {
	},
	Contents:{
		content:{}
	}
});
// -----------------------------------------------
